home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-25 | 46.5 KB | 1,598 lines | [TEXT/MPS ] |
-
- {[d-,h-,k+,o=100,q+,r+,rec+,t=2,u+,:+,j=15/20/25/30/35/40/45/50/57/1$]} {Pasmat opts!}
-
- UNIT SVEditions;
-
- {
- SVEditions.p
-
- Version 3.0d8
-
- Copyright © SRL Data 1992, 1993
-
- All rights reserved
-
- Produced by : SRL Data
- Originally Developed for UK.DTS
-
- The Edition Manager routines from the 7Edit example.
-
- Known incomplete bits-:
- i) Handling the mouse downs for Publishers and Subscribers is not all there-
- future versions will include double clicking to open the section options dialog,
- for example.
- ii) There are problems if an edition is moved from the Finder- there needs to
- be code added to handle orphaned sections.
- iii) We need to issue a warning if a document is disposed of containing
- sections that will be lost.
- }
-
- {
- Changes for 3.0d2 :
- 10-Feb-92 : NH : Tidy up dead vars etc.
- 11-Feb-92 : NH : Fix bug in read of saved document with sections - ReadSectionRecords
- 20-Feb-92 : NH : Put in new code to handle section position changes due to paste, key etc.
- DoTEPasteSectionRecalc,
- DoTEDeleteSectionRecalc,
- DoTECutSectionRecalc,
- DoTEKeySectionRecalc,
- KeyOKinSubscriber,
- DoSectionRecalc
- 22-Feb-92: NH : Code the 'styl' part of editions.
- 25-Feb-92: NH : Fix publisher borders clipping.
- 26-Feb-92: NH : Draw Borders to edge of printed page not window.
- 27-Feb-92: NH : gCurrSection zapped.
- 28-Feb-92: NH : PublishText via AppleEvent
- 18-Mar-92: NH : Old comments updates/zapped
- 19-Mar-92: NH : Fix Edition code so finder can open publisher etc.
-
- Changes for 3.0d4 :
- 9-Jul-92: NH : AEInteractWithUser before NewPublisherDialog
-
- }
-
- INTERFACE
-
- USES MemTypes, QuickDraw, OSIntf, ToolIntf, Traps, Menus, Packages, PPCToolbox, Editions, Printing,
- SVEditGlobals, SVEditUtils;
-
- PROCEDURE AddSection(newSection: SectHandle;
- aDocument: DPtr);
-
- PROCEDURE CreateSection(EMSection : SectionHandle;
- sectionID : INTEGER;
- theStart : INTEGER;
- theEnd : INTEGER;
- aDocument : DPtr;
- theBorder : RgnHandle);
-
- PROCEDURE DeleteASection(sectToDelete: SectHandle;
- theDoc: DPtr);
-
- PROCEDURE AssocAllSections(theDoc: DPtr);
-
- {routines for writing out and reading in section resources}
- {rAliasType and rSectionType resources}
-
- PROCEDURE ReadAllSectionResources(aDoc: DPtr);
-
- PROCEDURE ReadSectionRecords(aDoc: DPtr);
-
- PROCEDURE ReadASection(aSectHandle: SectHandle);
-
- PROCEDURE SaveASection(aSection: SectHandle;
- count: INTEGER);
-
- PROCEDURE SaveSections(aDocument: DPtr);
-
- {routines for writing out editions}
-
- PROCEDURE ReadAnEdition(mySectHdl: SectionHandle);
-
- PROCEDURE WriteAllEditions(aDocument: DPtr);
-
- PROCEDURE WriteAnEdition(mySectHdl: SectionHandle);
-
- {routines for handling the section borders}
-
- FUNCTION GetSection(theStartPos, theEndPos: INTEGER;
- aDoc: DPtr): SectHandle;
-
- PROCEDURE RecalcBorders(aDoc: DPtr;
- invalidate: BOOLEAN);
-
- PROCEDURE SetSelectionRgn(theTEHandle: TEHandle;
- posStart, posEnd: INTEGER;
- VAR theSelRgn: RgnHandle);
-
- PROCEDURE ShowSectionBorders(aDoc: DPtr);
-
- PROCEDURE DoTEPasteSectionRecalc(theDoc : DPtr);
-
- PROCEDURE DoTEDeleteSectionRecalc(theDoc : DPtr);
-
- PROCEDURE DoTECutSectionRecalc(theDoc : DPtr);
-
- PROCEDURE DoTEKeySectionRecalc(theDoc : DPtr; theChar:CHAR);
-
- {utility routines}
-
- FUNCTION GetERefCon(EMSection: SectionHandle): SectHandle;
-
- PROCEDURE SetERefCon(EMSection: SectionHandle;
- aSectHandle: SectHandle);
-
- PROCEDURE DeRegisterAllSections(aDoc: DPtr);
-
- FUNCTION GetHandleToText(aTEHandle: TEHandle;
- theStart, theEnd: INTEGER): Handle;
-
- {now the routines for dealing with the user interface issues}
-
- PROCEDURE DoSectionOptions(theDoc: DPtr);
-
- PROCEDURE DoSubscribe(theDoc: DPtr);
-
- FUNCTION GetEditionContainer(theDoc: DPtr; VAR theFSSpec:FSSpec): OSErr;
-
- FUNCTION PublishText(theDoc: DPtr; theFSSpec:FSSpecPtr): OSErr;
-
- FUNCTION KeyOKinSubscriber(whatKey:Char):BOOLEAN;
-
- IMPLEMENTATION
-
- USES AppleEvents;
-
- {*-----------------------------------------------------------------------
- Name: GetERefCon
- Purpose: Return the sectHandle (our own type) stored in
- the refcon of the SectionRecord.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- FUNCTION GetERefCon(EMSection: SectionHandle): SectHandle;
-
- VAR
- aSectHandle : SectHandle;
-
- BEGIN
- {returns the current refcon for this section as a SectHandle}
- aSectHandle := SectHandle(EMSection^^.refCon);
- GetERefCon := aSectHandle;
- END;
-
- {*-----------------------------------------------------------------------
- Name: SetERefCon
- Purpose: Store a handle to our own SectRecord in the refcon
- field of the SectionRecord.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE SetERefCon(EMSection: SectionHandle;
- aSectHandle: SectHandle);
-
- BEGIN
- {set up the refcon for the given section}
- EMSection^^.refCon := ORD4(aSectHandle);
- END;
-
- {*-----------------------------------------------------------------------
- Name: AddSection
- Purpose: Add our own section record to the document linked
- list. Set up the first and last section variables.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE AddSection(newSection: SectHandle;
- aDocument: DPtr);
-
-
- BEGIN
- (*
- add the section to the document
- *)
- aDocument^.numSections := aDocument^.numSections + 1;
-
- (*
- if not NIL, add the new section to the list after the last element
- *)
- IF (aDocument^.lastSection <> NIL) THEN
- aDocument^.lastSection^^.fNextSection := newSection
- ELSE
- aDocument^.firstSection := newSection;
-
- aDocument^.lastSection := newSection;
- newSection^^.fNextSection := NIL;
- END;
-
- {*-----------------------------------------------------------------------
- Name: CreateSection
- Purpose: Create a new section record to hold a Publisher or
- Subscriber. Link this to the SectionRecord.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE CreateSection(EMSection : SectionHandle;
- sectionID : INTEGER;
- theStart : INTEGER;
- theEnd : INTEGER;
- aDocument : DPtr;
- theBorder : RgnHandle);
-
- VAR
- newSection : SectHandle;
-
- BEGIN
- (*
- create a section and call AddSection to add it to the list
- *)
- newSection := SectHandle(NewHandle(SizeOf(sectRec)));
-
- IF (newSection<>NIL) THEN
- BEGIN
- newSection^^.fSectionID := sectionID;
- newSection^^.fNextSection := NIL;
- newSection^^.fSectHandle := EMSection;
- newSection^^.fStart := theStart;
- newSection^^.fEnd := theEnd;
- newSection^^.fCount := theEnd - theStart;
- newSection^^.fBorderRgn := theBorder;
- newSection^^.fDocument := aDocument;
-
- (*
- put a reference to our section record in the section's refCon field
- *)
- SetERefCon(EMSection, newSection);
- AddSection(newSection, aDocument);
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: DeleteASection
- Purpose: Delete the section from the list.
- Called when 'Cancel Publisher/Subscriber is chosen in
- the 'Section Options' dialog.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE DeleteASection(sectToDelete: SectHandle;
- theDoc: DPtr);
-
- VAR
- currSect : SectHandle;
- prevSect : SectHandle;
-
- BEGIN
- currSect := theDoc^.firstSection;
- prevSect := NIL;
-
- WHILE currSect <> NIL DO
- BEGIN
- IF (currSect = sectToDelete) THEN
- BEGIN
- (*
- unlink the section from the list
- *)
- IF (prevSect <> NIL) THEN
- prevSect^^.fNextSection := currSect^^.fNextSection;
- IF (currSect = theDoc^.firstSection) THEN
- theDoc^.firstSection := NIL;
- IF (currSect = theDoc^.lastSection) THEN
- theDoc^.lastSection := NIL;
- END;
- prevSect := currSect;
- currSect := currSect^^.fNextSection;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: ReadASection
- Purpose: Read in a section from disk
- Read in the rAliasType and rsectionType resources and register
- the section with the document.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE ReadASection(aSectHandle: SectHandle);
-
- VAR
- aSectionHandle: SectionHandle;
- anAlias : AliasHandle;
- err : OSErr;
- myFSSpec : FSSpec;
- ignore : BOOLEAN;
-
- BEGIN
- {read in the rAliasType and rSectionType resources}
-
- aSectionHandle := SectionHandle(Get1Resource(rSectionType, aSectHandle^^.fSectionID));
- err := HandtoHand(Handle(aSectionHandle));
- aSectHandle^^.fSectHandle := aSectionHandle;
- SetERefCon(aSectionHandle, aSectHandle);
-
- anAlias := AliasHandle(Get1Resource(rAliasType, aSectHandle^^.fSectionID));
- err := HandtoHand(Handle(anAlias));
- aSectionHandle^^.alias := anAlias;
-
- {now register the section}
-
- err := ResolveAlias(NIL, aSectionHandle^^.alias, myFSSpec, ignore);
- IF err <> noErr THEN
- BEGIN
- ShowError('Resolve Alias', err);
- Exit(ReadASection);
- END;
-
- err := RegisterSection(myFSSpec, aSectionHandle, ignore);
-
- IF (err <> noErr) AND
- (err <> notThePublisherWrn) AND
- (err <> multiplePublisherWrn) THEN
- BEGIN
- ShowError('RegisterSection', err);
- Exit(ReadASection);
- END;
- SetSelectionRgn(aSectHandle^^.fDocument^.theText, aSectHandle^^.fStart, aSectHandle^^.fEnd,
- aSectHandle^^.fBorderRgn);
- InvalRgn(aSectHandle^^.fBorderRgn);
- END;
-
- {*-----------------------------------------------------------------------
- Name: ReadAllSectionResources
- Purpose: Call the above routine to read in the resources for
- each section in the document.
- -----------------------------------------------------------------------*}
- {$S Editions}
-
- PROCEDURE ReadAllSectionResources(aDoc: DPtr);
-
- VAR
- theSection : SectHandle;
-
- BEGIN
- {read in each section resource}
- theSection := aDoc^.firstSection;
- WHILE theSection <> NIL DO
- BEGIN
- ReadASection(theSection);
- theSection := theSection^^.fNextSection;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: ReadSectionRecords
- Purpose: Read in all the 'sect' resources and form list
- of sections in the document. This is called from the
- main read document routine.
- -----------------------------------------------------------------------*}
- {$S Editions}
-
- PROCEDURE ReadSectionRecords(aDoc: DPtr);
-
- VAR
- theID : INTEGER;
- aSectHandle : SectHandle;
- err : OSErr;
- theCount : INTEGER;
-
- BEGIN
- {read in all the 'sect' resources for our document's sections}
- theCount := aDoc^.numSections;
- IF theCount = 0 THEN
- Exit(ReadSectionRecords);
- aDoc^.numSections := 0;
- FOR theID := 1 TO theCount DO
- BEGIN
- aSectHandle := SectHandle(Get1Resource('SECT', theID));
- err := HandtoHand(Handle(aSectHandle));
- {now add it to the list}
- IF aSectHandle <> NIL THEN
- AddSection(aSectHandle, aDoc);
- {here we should recalculate the region for the bounds}
- aSectHandle^^.fBorderRgn := NewRgn;
- { Bug fix : fill in the fdocument field }
- aSectHandle^^.fDocument := aDoc;
- END;
- {set numsections to NIL, so we can get an accurate result from AddSection}
- END;
-
- {*-----------------------------------------------------------------------
- Name: SaveASection
- Purpose: Write out the 'sect', rAliasType and rSectionType resources
- to file. Called when the document is saved.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE SaveASection(aSection: SectHandle;
- count: INTEGER);
-
- VAR
- EMSection : SectionHandle;
- err : OSErr;
- tempHandle : Handle;
-
- BEGIN
- HLock(Handle(aSection));
- {save this section as its component rAliasType and rSectionType resource}
- {also save as our own section record as a 'sect' resource}
- EMSection := aSection^^.fSectHandle;
- tempHandle := Handle(EMSection);
- err := HandtoHand(tempHandle);
- HLock(Handle(EMSection));
- AddResource(tempHandle, rSectionType, EMSection^^.sectionID, '');
- err := ResError;
- IF err <> noErr THEN
- BEGIN
- ShowError('AddResource- rSectionType', err);
- Exit(SaveASection);
- END;
-
- {now add the alias resource}
- tempHandle := Handle(EMSection^^.alias);
- err := HandtoHand(tempHandle);
- AddResource(tempHandle, rAliasType, EMSection^^.sectionID, '');
- IF err <> noErr THEN
- BEGIN
- ShowError('AddResource- rAliasType', err);
- Exit(SaveASection);
- END;
-
- {now add our own resource- for now all the record, although we only need a few fields}
- tempHandle := Handle(aSection);
- err := HandtoHand(tempHandle);
- AddResource(tempHandle, 'SECT', count, '');
- IF err <> noErr THEN
- BEGIN
- ShowError('AddResource- SECT', err);
- Exit(SaveASection);
- END;
-
- HUnlock(Handle(aSection));
- HUnlock(Handle(EMSection));
- END;
-
- {*-----------------------------------------------------------------------
- Name: SaveSections
- Purpose: Called to go down to the section list and call SaveASection
- for each one.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE SaveSections(aDocument: DPtr);
-
- VAR
- err : OSErr;
- currSection : SectHandle;
- count : INTEGER;
-
- BEGIN
- {go down the list and save each of the sections}
- {the resource file is already open for writing}
- count := 1;
- err := ResError;
- IF err <> noErr THEN
- BEGIN
- ShowError('HOpenResFile', err);
- Exit(SaveSections);
- END;
-
- {now go down the list}
- currSection := aDocument^.firstSection;
- WHILE currSection <> NIL DO
- BEGIN
- SaveASection(currSection, count);
- currSection := currSection^^.fNextSection;
- count := count + 1;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: AssocAllSections
- Purpose: Associate all the sections in a document with the document.
- Called on a SaveAs.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE AssocAllSections(theDoc: DPtr);
-
- VAR
- aSection : SectHandle;
- EMSection : SectionHandle;
- err : OSErr;
-
- BEGIN
- {called by DoSaveAs. Make sure sections are registered with this document}
- aSection := theDoc^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- EMSection := aSection^^.fSectHandle;
- err := AssociateSection(EMSection, @theDoc^.theFSSpec);
- aSection := aSection^^.fNextSection;
- END;
- END;
-
-
- {*-----------------------------------------------------------------------
- Name: KeyOKinSubscriber
- Purpose: Detects arrow keys.
- -----------------------------------------------------------------------*}
- (*$S Editions*)
-
- FUNCTION KeyOKinSubscriber(whatKey:Char):BOOLEAN;
- CONST kChLeft = 28;
- kChRight = 29;
- kChUp = 30;
- kChDown = 31;
-
- BEGIN
- KeyOKinSubscriber := (whatKey=CHR(kChUp)) OR
- (whatKey=CHR(kChDown)) OR
- (whatKey=CHR(kChLeft)) OR
- (whatKey=CHR(kChRight));
-
- END; (*KeyOKinSubscriber*)
-
- {*-----------------------------------------------------------------------
- Name: ShiftSection
- Purpose: Moves a section by howMany characters.
- -----------------------------------------------------------------------*}
-
- PROCEDURE ShiftSection(whichSection:SectHandle; howMany:INTEGER);
- BEGIN
- whichSection^^.fStart := whichSection^^.fStart + howMany;
- whichSection^^.fEnd := whichSection^^.fEnd + howMany;
- END; (* ShiftSection *)
-
- {*-----------------------------------------------------------------------
- Name: DoSectionRecalc
- Purpose: Keeps track of the positions of the sections.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE DoSectionRecalc(theDoc : DPtr; toAdd:INTEGER);
- VAR
- theStartPos : INTEGER;
- theEndPos : INTEGER;
- aSection : SectHandle;
- oldSectionStart : INTEGER;
- oldSectionEnd : INTEGER;
- wasChanged : Boolean;
- oldPort : GrafPtr;
-
- BEGIN
- (*
- Work thru all sections -
- 1) Those spanning area of modification get modified or zapped
- 2) Those after get shifted back or forwards.
-
- Sorry it is so complicated - there's a lot of possibilities
- *)
- theStartPos := theDoc^.theText^^.selStart;
- theEndPos := theDoc^.theText^^.selEnd;
-
- aSection := theDoc^.firstSection;
- WHILE (aSection <> NIL) DO
- BEGIN
- wasChanged := TRUE;
-
- oldSectionEnd := aSection^^.fEnd;
- oldSectionStart := aSection^^.fStart;
-
- IF (theEndPos < aSection^^.fStart) THEN
- ShiftSection(aSection, toAdd - (theEndPos-theStartPos))
- ELSE
- IF (theStartPos = aSection^^.fStart) THEN
- IF (theEndPos = aSection^^.fStart) THEN
- ShiftSection(aSection, toAdd - (theEndPos-theStartPos))
- ELSE
- IF (theEndPos >= aSection^^.fEnd) THEN (* section becomes pasted text *)
- aSection^^.fEnd := aSection^^.fStart + toAdd
- ELSE (* insert pasted text *)
- aSection^^.fEnd := aSection^^.fEnd + toAdd - (theEndPos-theStartPos)
- ELSE
- IF (theStartPos< aSection^^.fStart) THEN
- aSection^^.fStart := theStartPos + toAdd (* move start to end of pasted text *)
- ELSE
- IF (theStartPos <= aSection^^.fEnd) THEN
- IF (theEndPos >= aSection^^.fEnd) THEN (* end of section becomes pasted text *)
- aSection^^.fEnd := theStartPos + toAdd
- ELSE (* insert pasted text into section *)
- aSection^^.fEnd := aSection^^.fEnd + toAdd - (theEndPos-theStartPos)
- ELSE
- wasChanged := FALSE;
-
- IF wasChanged THEN
- BEGIN
- aSection^^.fCount := aSection^^.fEnd - aSection^^.fStart;
-
- IF theDoc^.showBorders THEN
- BEGIN (* Force an update of the borders - later*)
- GetPort(oldPort);
- SetPort(theDoc^.theWindow);
-
- SetSelectionRgn(theDoc^.theText,
- oldSectionStart,
- oldSectionEnd,
- aSection^^.fBorderRgn);
- InvalRgn(aSection^^.fBorderRgn);
-
- SetPort(oldPort);
- END;
-
- END;
-
- aSection := aSection^^.fNextSection;
- END;
- END; (* DoSectionRecalc *)
-
- {*-----------------------------------------------------------------------
- Name: ReadAnEdition
- Purpose: Read the latest version of an edition from disk.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE ReadAnEdition(mySectHdl: SectionHandle);
- VAR
- aSectHandle : SectHandle;
- theRefNum : EditionRefNum;
- err : OSErr;
- p : Ptr;
- theStylHandle : Handle;
- cutSize : LONGINT;
- stylSize : LONGINT;
- stylErr : OsErr;
-
- BEGIN
- p := NIL;
- theStylHandle := NIL;
-
- IF mySectHdl = NIL THEN
- BEGIN
- ShowError('mySectHdl is NIL', 0);
- Exit(ReadAnEdition);
- END;
-
- aSectHandle := SectHandle(GetERefCon(mySectHdl));
- IF aSectHandle = NIL THEN
- BEGIN
- ShowError('aSectHandle is NIL', 0);
- Exit(ReadAnEdition);
- END;
-
- GetDateTime(mySectHdl^^.mdDate);
-
- {read a subscriber in from disk. Usually in response to a sectionread event}
- err := OpenEdition(mySectHdl, theRefNum);
-
- IF err <> noErr THEN
- BEGIN
- ShowError('OpenEdition in ReadAnEdition', err);
- Exit(ReadAnEdition);
- END;
-
- err := EditionHasFormat(theRefNum, 'TEXT', cutSize);
- IF err <> noErr THEN
- BEGIN
- ShowError('EditionHasFormat', err);
- Exit(ReadAnEdition);
- END;
-
- stylErr := EditionHasFormat(theRefNum, 'styl', stylSize);
-
- err := SetEditionFormatMark(theRefNum, 'TEXT', 0);
- IF err <> noErr THEN
- BEGIN
- ShowError('SetEditionFormatMark', err);
- Exit(ReadAnEdition);
- END;
-
- {set up a buffer for the text we're going to read in}
- p := NewPtr(cutSize);
- IF (p = NIL) THEN
- BEGIN
- ShowError('Insufficient memory to read edition', MemError);
- Exit(ReadAnEdition);
- END;
-
- err := ReadEdition(theRefNum, 'TEXT', p, cutSize);
-
- IF (err <> noErr) THEN
- BEGIN
- ShowError('ReadEdition', err);
- Exit(ReadAnEdition);
- END;
-
- IF (stylErr = noErr) THEN
- BEGIN
- theStylHandle := NewHandle(stylSize);
- stylErr := SetEditionFormatMark(theRefNum, 'styl', 0);
- IF (stylErr = noErr) THEN
- IF (theStylHandle<>NIL) THEN
- BEGIN
- HLock(theStylHandle);
- stylErr := ReadEdition(theRefNum, 'styl', theStylHandle^, stylSize);
- HUnLock(theStylHandle);
- END;
- END;
-
- err := CloseEdition(theRefNum, TRUE);
- IF err <> noErr THEN
- BEGIN
- ShowError('CloseEdition', err);
- Exit(ReadAnEdition);
- END;
-
- (*
- Ensure this section has a region and invalidate the old region
- *)
-
- IF (aSectHandle^^.fBorderRgn = NIL) THEN
- aSectHandle^^.fBorderRgn := NewRgn;
-
- SetSelectionRgn(aSectHandle^^.fDocument^.theText,
- aSectHandle^^.fStart,
- aSectHandle^^.fEnd,
- aSectHandle^^.fBorderRgn);
-
- InvalRgn(aSectHandle^^.fBorderRgn);
-
- {now insert the text in the right place by setting the selection range}
- {we want this to act like paste, but without putting the contents on the clipboard}
- {so we have to delete the current selection range and then insert our new text}
-
- (*
- Also fixup section info. for other moved sections
- *)
-
- TESetSelect(aSectHandle^^.fStart,
- aSectHandle^^.fEnd,
- aSectHandle^^.fDocument^.theText);
-
- DoSectionRecalc(aSectHandle^^.fDocument,
- cutSize);
-
- TEDelete(aSectHandle^^.fDocument^.theText);
- TEStylInsert(p, cutSize, StScrpHandle(theStylHandle), aSectHandle^^.fDocument^.theText);
-
- (*
- Now a little fix up - if the section was previously empty the
- DoSectionRecalc will have put the text in before the section.
- It's like that so you can type in before a subscriber in an
- otherwise empty document. So now pull the start of this section
- back to include the text we just added.
- *)
-
- aSectHandle^^.fStart := aSectHandle^^.fEnd - cutSize;
-
- (*
- Force redraw of this region
- *)
-
- SetSelectionRgn(aSectHandle^^.fDocument^.theText,
- aSectHandle^^.fStart,
- aSectHandle^^.fEnd,
- aSectHandle^^.fBorderRgn);
-
- InvalRgn(aSectHandle^^.fBorderRgn);
-
- DisposPtr(p);
-
- IF (theStylHandle<>NIL) THEN
- DisposHandle(theStylHandle);
- END;
-
- {*-----------------------------------------------------------------------
- Name: WriteAnEdition
- Purpose: Write out the latest version of an Edition.
- Called on a Save and on selecting WriteEdition now from
- the Publisher Options dialog.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE WriteAnEdition(mySectHdl: SectionHandle);
-
- VAR
- err : OSErr;
- aSectHandle : SectHandle;
- theRefNum : EditionRefNum;
- aHandle : Handle;
- theStylHandle : StScrpHandle;
- oldSelStart : INTEGER;
- oldSelEnd : INTEGER;
- theFSSpecPtr : FSSpecPtr;
-
- BEGIN
- aSectHandle := SectHandle(GetERefCon(mySectHdl));
- {alter the modification date for the section}
- GetDateTime(mySectHdl^^.mdDate);
- {write out the edition. Assume that it is a publisher for now}
- {subscribers will be opened for writing with OpenEdition}
-
- IF (aSectHandle^^.fDocument^.everSaved = FALSE) THEN
- theFSSpecPtr := NIL
- ELSE
- theFSSpecPtr := @aSectHandle^^.fDocument^.theFSSpec;
-
- err := OpenNewEdition(mySectHdl,
- 'SVED',
- theFSSpecPtr,
- theRefNum);
- IF err <> noErr THEN
- BEGIN
- ShowError('OpenNewEdition', err);
- Exit(WriteAnEdition);
- END;
-
- err := SetEditionFormatMark(theRefNum, 'TEXT', 0);
- IF err <> noErr THEN
- BEGIN
- ShowError('SetEditionFormatMark', err);
- Exit(WriteAnEdition);
- END;
-
- {now get a handle to the text to be written out}
- {use the same start and end positions for now, increasing and decreasing}
- {the selection will be implemented later}
-
- aHandle := GetHandleToText(aSectHandle^^.fDocument^.theText,
- aSectHandle^^.fStart,
- aSectHandle^^.fEnd);
- HLock(aHandle);
-
- {make sure the count is up to date}
- aSectHandle^^.fCount := aSectHandle^^.fEnd - aSectHandle^^.fStart;
-
- err := WriteEdition(theRefNum, 'TEXT', aHandle^, aSectHandle^^.fCount);
- IF err <> noErr THEN
- BEGIN
- ShowError('WriteEdition', err);
- Exit(WriteAnEdition);
- END;
- HUnlock(aHandle);
-
- oldSelStart := aSectHandle^^.fDocument^.theText^^.selStart;
- oldSelEnd := aSectHandle^^.fDocument^.theText^^.selEnd;
-
- TESetSelect(aSectHandle^^.fStart,aSectHandle^^.fEnd, aSectHandle^^.fDocument^.theText);
- theStylHandle := GetStylScrap(aSectHandle^^.fDocument^.theText);
- TESetSelect(oldSelStart,oldSelEnd, aSectHandle^^.fDocument^.theText);
-
- IF (theStylHandle<>NIL) THEN
- BEGIN
- err := SetEditionFormatMark(theRefNum, 'styl', 0);
- IF err <> noErr THEN
- BEGIN
- ShowError('SetEditionFormatMark for styl', err);
- Exit(WriteAnEdition);
- END;
- HLock(Handle(theStylHandle));
-
- err := WriteEdition(theRefNum,
- 'styl',
- Ptr(theStylHandle^),
- GetHandleSize(Handle(theStylHandle)));
- HUnLock(Handle(theStylHandle));
- END;
-
- {remember to save the section and alias records as resources later}
-
- {now close the edition}
-
- err := CloseEdition(theRefNum, TRUE);
- IF err <> noErr THEN
- BEGIN
- ShowError('CloseEdition', err);
- Exit(WriteAnEdition);
- END;
-
- (*
- Clean Up
- *)
-
- DisposHandle(aHandle);
- IF (theStylHandle<>NIL) THEN
- DisposHandle(Handle(theStylHandle));
-
- END; {WriteAnEdition}
-
- {*-----------------------------------------------------------------------
- Name: WriteAllEditions
- Purpose: Go down the list and call WriteAnEdition
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE WriteAllEditions(aDocument: DPtr);
-
- VAR
- aSection : SectHandle;
- EMSection : SectionHandle;
- err : OSErr;
-
- BEGIN
- {called on a Save, to write out all editions}
- aSection := aDocument^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- EMSection := aSection^^.fSectHandle;
- IF EMSection^^.kind = stPublisher THEN
- WriteAnEdition(EMSection);
- aSection := aSection^^.fNextSection;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: DeRegisterAllSections
- Purpose: Called on cancel Publisher/Subscriber and on a close.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE DeRegisterAllSections(aDoc: DPtr);
-
- VAR
- aSection : SectHandle;
- EMSection : SectionHandle;
- err : OSErr;
-
- BEGIN
- aSection := aDoc^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- EMSection := aSection^^.fSectHandle;
- err := UnRegisterSection(EMSection);
- aSection := aSection^^.fNextSection;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: GetHandleToText
- Purpose: Get a handle to the current text selection.
- Used to provide a preview on Create Publisher...
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- FUNCTION GetHandleToText(aTEHandle: TEHandle;
- theStart, theEnd: INTEGER): Handle;
-
- VAR
- err : OSErr;
- myHandle : Handle;
- p : PTR;
-
- BEGIN
- HLock(aTEHandle^^.hText);
- p := aTEHandle^^.hText^;
- p := POINTER(ORD4(p) + (theStart));
- err := PtrToHand(p, myHandle, (theEnd - theStart));
- HUnlock(aTEHandle^^.hText);
- GetHandleToText := myHandle;
- END; (* GetHandleToText *)
-
- {*-----------------------------------------------------------------------
- Name: FindLine
- Purpose: Find the line a character is in.
- Used to find to calculate the region to use for the Publisher/
- Subscriber borders.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- FUNCTION FindLine(thePos: INTEGER;
- theTEHandle: TEHandle): INTEGER;
-
- VAR
- Index : INTEGER;
- theFirstPos, theNextPos: INTEGER;
-
- BEGIN
- Index := 0;
-
- REPEAT
- BEGIN
- theFirstPos := theTEHandle^^.LineStarts[Index];
- theNextPos := theTEHandle^^.LineStarts[Index + 1];
- Index := Index + 1;
- END;
- UNTIL (((thePos >= theFirstPos) AND (thePos < theNextPos)) OR (Index >
- theTEHandle^^.nLines));
- FindLine := Index;
- END;
-
- {*-----------------------------------------------------------------------
- Name: DrawSelectionRgn
- Purpose: Given a text handle and a start and end position this routine
- will draw a section border around the selected text.
- Must allow for the case when the section has no text in it-
- but we still want to show it as a published section
- -----------------------------------------------------------------------*}
-
- PROCEDURE DrawSelectionRegion(theTEHandle : TEHandle;
- posStart : INTEGER;
- posEnd : INTEGER);
-
- VAR theSelRgn : RgnHandle;
-
- BEGIN
- theSelRgn := NewRgn;
-
- SetSelectionRgn(theTEHandle,posStart, posEnd,theSelRgn);
- FrameRgn(theSelRgn);
-
- DisposeRgn(theSelRgn);
-
- END; (* DrawSelectionRegion *)
-
- {*-----------------------------------------------------------------------
- Name: SetSelectionRgn
- Purpose: Given a text handle and a start and end position this routine
- will return the region which is necessary to draw a section
- border around the selected text.
- Must allow for the case when the section has no text in it-
- but we still want to show it as a published section
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE SetSelectionRgn(theTEHandle: TEHandle;
- posStart, posEnd: INTEGER;
- VAR theSelRgn: RgnHandle);
-
- VAR
- theStart : Point;
- theEnd : Point;
- startLine : INTEGER;
- endLine : INTEGER;
- theRect : RECT;
- theLeft : INTEGER;
- theRight : INTEGER;
- theBottom : INTEGER;
- theTop : INTEGER;
- slineHeight : INTEGER;
- elineHeight : INTEGER;
- theTStyle : TextStyle;
- fontAscent : INTEGER;
-
- BEGIN
- {first of all find out if the text is on the same line}
- startLine := FindLine(posStart, theTEHandle);
- endLine := FindLine(posEnd, theTEHandle);
-
- theStart := TEGetPoint(posStart, theTEHandle);
- theEnd := TEGetPoint(posEnd, theTEHandle);
-
- (*
- Get the line height info
- *)
- TEGetStyle(posStart, theTStyle, slineHeight, fontAscent, theTEHandle);
- TEGetStyle(posEnd, theTStyle, elineHeight, fontAscent, theTEHandle);
-
- IF startLine = endLine THEN
- BEGIN
- {use the start and end points to form the rectangle and draw this into the region}
- theStart.v := theStart.v - slineHeight;
- Pt2Rect(theStart, theEnd, theRect);
- InsetRect(theRect, - 1, - 1);
- RectRgn(theSelRgn, theRect);
- END
- ELSE
- BEGIN
- theLeft := theTEHandle^^.destRect.left;
- theRight := theTEHandle^^.destRect.right;
- theTop := theStart.v - slineHeight;
- theBottom := theEnd.v;
- OpenRgn;
- MoveTo(theStart.h, theStart.v - slineHeight);
- LineTo(theRight, theStart.v - slineHeight);
- LineTo(theRight, theEnd.v - elineHeight);
- LineTo(theEnd.h, theEnd.v - elineHeight);
- LineTo(theEnd.h, theEnd.v);
- LineTo(theLeft, theEnd.v);
- LineTo(theLeft, theStart.v);
- LineTo(theStart.h, theStart.v);
- LineTo(theStart.h, theStart.v - slineHeight);
- CloseRgn(theSelRgn);
- END;
-
- InsetRgn(theSelRgn, - 2, - 2);
-
- END;
-
- {*-----------------------------------------------------------------------
- Name: ShowSectionBorders
- Purpose: Show the borders for all the sections in a document.
- Show a Publisher border in 50% gray, a subscriber in 75% gray
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE ShowSectionBorders(aDoc: DPtr);
-
- VAR
- aSection : SectHandle;
-
- BEGIN
- PenNormal;
- PenSize(3, 3);
- PenPat(Gray);
- aSection := aDoc^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- IF aSection^^.fBorderRgn <> NIL THEN
- BEGIN
- SetSelectionRgn(aSection^^.fDocument^.theText,
- aSection^^.fStart,
- aSection^^.fEnd,
- aSection^^.fBorderRgn);
-
- IF aSection^^.fSectHandle^^.kind = stPublisher THEN
- PenPat(Gray)
- ELSE
- PenPat(dkGray);
-
- FrameRgn(aSection^^.fBorderRgn);
- PenNormal;
- END;
- aSection := aSection^^.fNextSection;
- END;
- PenNormal;
- END;
-
- {*-----------------------------------------------------------------------
- Name: RecalcBorders
- Purpose: Recalculate all the borders for the sections in a document.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- PROCEDURE RecalcBorders(aDoc: DPtr;
- invalidate: BOOLEAN);
-
- VAR
- aSection : SectHandle;
-
- BEGIN
- {go down the section list and recalculate all the borders}
- aSection := aDoc^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- IF aSection^^.fBorderRgn <> NIL THEN
- BEGIN
- IF invalidate THEN
- InvalRgn(aSection^^.fBorderRgn);
- SetSelectionRgn(aSection^^.fDocument^.theText, aSection^^.fStart, aSection^^.fEnd,
- aSection^^.fBorderRgn);
- IF invalidate THEN
- InvalRgn(aSection^^.fBorderRgn);
- END;
- aSection := aSection^^.fNextSection;
- END;
- END;
-
- {*-----------------------------------------------------------------------
- Name: GetSection
- Purpose: Given a start and end of a selection- return the section
- handle if it is in a Publisher or Subscriber.
- -----------------------------------------------------------------------*}
-
- {$S Editions}
-
- FUNCTION GetSection(theStartPos, theEndPos: INTEGER;
- aDoc: DPtr): SectHandle;
-
- VAR
- foundSection : SectHandle;
- aSection : SectHandle;
-
- BEGIN
- {returns the section handle for the section between theStartPos and theEndPos}
- foundSection := NIL;
- aSection := aDoc^.firstSection;
- WHILE aSection <> NIL DO
- BEGIN
- IF ((theStartPos >= aSection^^.fStart) AND (theEndPos <= aSection^^.fEnd)) THEN
- foundSection := aSection;
- aSection := aSection^^.fNextSection;
- END;
- GetSection := foundSection;
- END;
-
- {*-----------------------------------------------------------------------
- Name: DoTEPasteSectionRecalc
- Purpose: Keeps track of the positions of the sections call before a
- TEPaste or TEStylPaste.
- -----------------------------------------------------------------------*}
-
- PROCEDURE DoTEPasteSectionRecalc(theDoc : DPtr);
- VAR
- toAdd : INTEGER;
-
- BEGIN
- toAdd := TEGetScrapLen;
- DoSectionRecalc(theDoc, toAdd);
- END; (* DoTEPasteSectionRecalc *)
-
- {*-----------------------------------------------------------------------
- Name: DoTEDeleteSectionRecalc
- Purpose: Keeps track of the positions of the sections call before a
- TEDelete.
- -----------------------------------------------------------------------*}
-
- PROCEDURE DoTEDeleteSectionRecalc(theDoc : DPtr);
- BEGIN
- DoSectionRecalc(theDoc, 0);
- END; (* DoTEDeleteSectionRecalc *)
-
- {*-----------------------------------------------------------------------
- Name: DoTECutSectionRecalc
- Purpose: Keeps track of the positions of the sections call before a
- TECut.
- -----------------------------------------------------------------------*}
-
- PROCEDURE DoTECutSectionRecalc(theDoc : DPtr);
- BEGIN
- DoSectionRecalc(theDoc, 0);
- END; (* DoTECutSectionRecalc *)
-
- {*-----------------------------------------------------------------------
- Name: DoTEKeySectionRecalc
- Purpose: Keeps track of the positions of the sections call before a
- TECut.
- -----------------------------------------------------------------------*}
-
- PROCEDURE DoTEKeySectionRecalc(theDoc : DPtr; theChar:CHAR);
- VAR
- toAdd : INTEGER;
- oldStart : INTEGER;
-
- BEGIN
- IF NOT KeyOKinSubscriber(theChar) THEN (* is it a cursor motion key? - yes = ignore *)
- BEGIN
- IF theChar=CHR(8) THEN
- IF (theDoc^.theText^^.selStart<theDoc^.theText^^.selEnd) THEN
- toAdd := 0
- ELSE
- BEGIN
- toAdd := -1;
- oldStart := theDoc^.theText^^.selStart;
-
- theDoc^.theText^^.selStart := GreaterOf(oldStart-1,0);
- DoSectionRecalc(theDoc, 0);
- theDoc^.theText^^.selStart := oldStart;
- END
- ELSE
- toAdd := 1;
-
- IF (toAdd<>-1) THEN
- DoSectionRecalc(theDoc, toAdd);
- END;
- END; (* DoTEKeySectionRecalc *)
-
- {*-----------------------------------------------------------------------
- Name: GetEditionContainer
- Purpose: Gets the Edition Container to put the edition into.
- The main user interface stuff.
- Puts up the new publisher dialog.
- Should check kAEInteractWithUser etc.
- -----------------------------------------------------------------------*}
-
- {$S Main}
-
- FUNCTION GetEditionContainer(theDoc: DPtr; VAR theFSSpec:FSSpec): OSErr;
-
- VAR
- err : OSErr;
- myReply : NewPublisherReply;
- theStart : INTEGER;
- theEnd : INTEGER;
- myHandle : Handle;
-
- BEGIN
- err := noErr;
-
- {get default editionContainer to use, using last volume and folder}
-
- myReply.container.thePart := kPartsNotUsed;
-
- err := GetLastEditionContainerUsed(myReply.container);
-
- IF (err=fnfErr) THEN
- err := noErr;
-
- theStart := theDoc^.theText^^.selStart;
- theEnd := theDoc^.theText^^.selEnd;
-
- IF (err=noErr) THEN
- BEGIN
- {
- Create a handle containing the text to be published for previewing -
- need to ask the user where to put the data
- }
- myHandle := GetHandleToText(theDoc^.theText, theStart, theEnd);
-
- myReply.usePart := FALSE;
- myReply.preview := myHandle;
- myReply.previewFormat := 'TEXT';
- myReply.container.theFile.name := ''; (* Want a proper prompted name here *)
- HLock(myHandle);
-
- (* Should take suggested name and avoid dialog if no user interaction *)
-
- err := AEInteractWithUser(kAEDefaultTimeout, nil, nil);
-
- IF (err=noErr) THEN
- err := NewPublisherDialog(myReply);
- HUnlock(myHandle);
- DisposHandle(myHandle);
- END;
-
- {IF user cancelled, THEN exit from this routine}
-
- IF (err=noErr) THEN
- IF (myReply.canceled) THEN
- err := userCanceledErr;
-
- IF (err=noErr) THEN
- IF (myReply.replacing) THEN
- err := FSpDelete(myReply.container.theFile);
-
- IF (err = noErr) THEN
- theFSSpec := myReply.container.theFile;
-
- GetEditionContainer := err;
- END; {GetEditionContainer}
-
-
- {*-----------------------------------------------------------------------
- Name: PublishText
- Purpose: Publishes the current selection of theDoc.
- The main user interface stuff.
- Puts up the new publisher dialog - if theFSSpec=NIL
- Writes the new edition out to disk.
- -----------------------------------------------------------------------*}
-
- {$S Main}
-
- FUNCTION PublishText(theDoc: DPtr; theFSSpec:FSSpecPtr): OSErr;
-
- VAR
- myReply : NewPublisherReply;
- mySectHdl : SectionHandle;
- err : OSErr;
- mysectionID : LONGINT;
- pubFSSpec : FSSpecPtr;
- theStart : INTEGER;
- theEnd : INTEGER;
- theRgnHandle : RgnHandle;
-
- BEGIN
-
- mysectionID := theDoc^.lastID + 1;
- theDoc^.lastID := mysectionID;
-
- {get default editionContainer to use, using last volume and folder}
-
- myReply.container.thePart := kPartsNotUsed;
-
- err := GetLastEditionContainerUsed(myReply.container);
-
- IF (err=fnfErr) THEN
- err := noErr;
-
- theStart := theDoc^.theText^^.selStart;
- theEnd := theDoc^.theText^^.selEnd;
-
- {don't want to publish an empty section}
-
- IF (theEnd - theStart = 0) THEN
- err := userCanceledErr;
-
- myReply.container.theFile := theFSSpec^;
-
- {now publish this section}
-
- IF (err = noErr) THEN
- err := CreateEditionContainerFile(myReply.container.theFile, 'SVED', 0);
-
- {check IF the file has been saved, IF not set pubCFS to NIL}
-
- IF (theDoc^.everSaved = FALSE) THEN
- pubFSSpec := NIL
- ELSE
- pubFSSpec := @theDoc^.theFSSpec;
-
- {get the region to encompass the selection}
-
- theRgnHandle := NewRgn;
- SetSelectionRgn(theDoc^.theText, theDoc^.theText^^.selStart, theDoc^.theText^^.selEnd,
- theRgnHandle);
-
- InvalRgn(theRgnHandle);
-
- {create a publisher section}
- IF (err=noErr) THEN
- BEGIN
- err := NewSection(myReply.container,
- pubFSSpec,
- stPublisher,
- mysectionID,
- pumOnSave,
- mySectHdl);
-
- {now add this section to our document list}
-
- IF (err = noErr) THEN
- CreateSection(mySectHdl, mysectionID, theStart, theEnd, theDoc, theRgnHandle);
- END;
-
- {now write out the edition to file}
-
- IF (err=noErr) THEN
- WriteAnEdition(mySectHdl);
-
- PublishText := err;
- END; {PublishText}
-
- {*-----------------------------------------------------------------------
- Name: DoSubscribe
- Purpose: Subscribe to a published section. Puts up the subscriber
- dialog, creates and adds the new section.
- -----------------------------------------------------------------------*}
-
- {$S Main}
-
- PROCEDURE DoSubscribe(theDoc: DPtr);
-
- VAR
- myReply : NewSubscriberReply;
- mySectHdl : SectionHandle;
- mysectionID : LONGINT;
- subFSSpec : FSSpecPtr; {the fsspec for the subscriber file}
- err : OSErr;
- theStart : INTEGER;
- theEnd : INTEGER;
-
- BEGIN
-
- mysectionID := theDoc^.lastID + 1;
- theDoc^.lastID := mysectionID;
- err := noErr;
-
- {get default editionContainer to use, using last volume and folder}
- { myreply.container.thePart := kPartNumberUnknown;}
- myReply.formatsMask := kTEXTformatMask;
-
- err := GetLastEditionContainerUsed(myReply.container);
- IF (err <> noErr) & (err <> fnfErr) THEN
- BEGIN
- ShowError('GetLastEditionContainerUsed', err);
- Exit(DoSubscribe);
- END;
-
- {put up the subscriber dialog}
- err := NewSubscriberDialog(myReply);
- IF err <> noErr THEN
- BEGIN
- ShowError('NewSubscriberDialog', err);
- Exit(DoSubscribe);
- END;
-
- {IF user cancelled, THEN exit from this routine}
- IF myReply.canceled THEN
- Exit(DoSubscribe);
-
- {check IF the file has been saved, IF not set pubCFS to NIL}
- IF (theDoc^.everSaved = FALSE) THEN
- subFSSpec := NIL
- ELSE
- subFSSpec := @theDoc^.theFSSpec;
-
- {create a publisher section}
- err := NewSection(myReply.container,
- subFSSpec,
- stSubscriber,
- mysectionID,
- sumAutomatic,
- mySectHdl);
-
- IF err <> noErr THEN
- BEGIN
- ShowError('NewSection', err);
- Exit(DoSubscribe);
- END;
-
- theStart := theDoc^.theText^^.selStart;
- theEnd := theDoc^.theText^^.selEnd;
-
- {now add this section to our document list}
-
- CreateSection(mySectHdl, mysectionID, theStart, theEnd, theDoc, NIL);
-
- {read the subscriber in from disk}
-
- ReadAnEdition(mySectHdl);
-
- END; {DoSubscribe}
-
- {*-----------------------------------------------------------------------
- Name: DoSectionOptions
- Purpose: Put up the section option dialogs for a publisher
- or subscriber. Handle all the various options.
- Note that 'Find Publisher' doesn't work yet.
- -----------------------------------------------------------------------*}
-
- {$S Main}
-
- PROCEDURE DoSectionOptions(theDoc: DPtr);
-
- VAR
- err : OSErr;
- reply : SectionOptionsReply;
- theInfo : EditionInfoRecord;
- theAlias : Handle;
- theFormatType : FormatType;
- currSection : SectHandle;
-
- BEGIN
- currSection := GetSection(theDoc^.theText^^.selStart,
- theDoc^.theText^^.selEnd,
- theDoc);
-
- reply.sectionH := currSection^^.fSectHandle;
- err := SectionOptionsDialog(reply);
- WITH reply DO
- BEGIN
- IF NOT reply.canceled THEN
- BEGIN
- {find out IF there is any action needed}
- IF action = 'read' THEN
- {read the latest version of a subscriber}
- ReadAnEdition(currSection^^.fSectHandle)
- ELSE
- IF action = 'writ' THEN
- {write out the latest version of a publisher to disk}
- WriteAnEdition(currSection^^.fSectHandle)
- ELSE
- IF (action = 'goto') THEN {goto a published section}
- BEGIN
- err := GetEditionInfo(currSection^^.fSectHandle, theInfo);
-
- IF (err <> noErr) THEN
- ShowError('GetEditionInfo', err);
-
- err := GotoPublisherSection(theInfo.container);
-
- IF (err <> noErr) THEN
- ShowError('GotoPublisherSection', err);
- END
- ELSE
- IF (action = 'cncl') THEN {cancel a publisher or subscriber}
- BEGIN
- {unRegister the section and delete from our own list}
- {should have a free PROCEDURE which frees the structures}
- {associated with a section}
- err := UnRegisterSection(currSection^^.fSectHandle);
- DeleteASection(currSection, theDoc);
-
- {IF this is the ONLY publisher writing data to this edition}
- {we should delete the container file as well}
- END;
- END;
- END;
- END;
-
- END.
-